{
 "cells": [
  {
   "cell_type": "code",
   "id": "7f67158653697ba8",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-07-27T22:48:37.234155Z",
     "start_time": "2025-07-27T22:48:35.263195Z"
    }
   },
   "source": [
    "import json\n",
    "import torch\n",
    "from torch.utils.data import Dataset\n",
    "from modelscope import AutoTokenizer\n",
    "from dataset import utils"
   ],
   "outputs": [],
   "execution_count": 1
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-27T22:48:42.140402Z",
     "start_time": "2025-07-27T22:48:42.118147Z"
    }
   },
   "cell_type": "code",
   "source": [
    "## 打开json格式的微调训练\n",
    "with open(\"dataset/chatGLM3_dataFormatted_sample.json\", \"r\", encoding=\"UTF-8\") as j_file:\n",
    "    j_dict = json.load(j_file)"
   ],
   "id": "23612023b6e4d2fe",
   "outputs": [],
   "execution_count": 2
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-27T22:48:43.580355Z",
     "start_time": "2025-07-27T22:48:43.528840Z"
    }
   },
   "cell_type": "code",
   "source": [
    "## 定义模型路径\n",
    "model_dir = \"C:\\\\Users\\\\16014\\\\.cache\\\\modelscope\\\\hub\\\\models\\\\ZhipuAI\\\\chatglm3-6b\"\n",
    "tokenizer = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True)"
   ],
   "id": "d8e53cd4e5a2a8ec",
   "outputs": [],
   "execution_count": 3
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-27T22:48:44.786420Z",
     "start_time": "2025-07-27T22:48:44.776302Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 定义一个名为ChatDataset的类，该类继承自Dataset类，用于处理聊天数据集\n",
    "class ChatDataset(Dataset):\n",
    "    # 初始化函数，接收以下参数：\n",
    "    # conversations: 一个包含对话数据的字典，默认为j_dict\n",
    "    # tokenizer: 用于tokenization的工具，默认为tokenizer\n",
    "    # max_tokens: 最大token数量限制，默认为None\n",
    "    def __init__(self, conversations: {} = j_dict, tokenizer=tokenizer, max_tokens=None):\n",
    "        # 通过super()调用父类Dataset的初始化函数\n",
    "        super(ChatDataset, self).__init__()\n",
    "\n",
    "        # 使用utils.preprocess函数预处理对话数据，得到处理后的数据字典\n",
    "        data_dict = utils.preprocess(conversations, tokenizer, max_tokens)\n",
    "\n",
    "        # 从处理后的数据字典中提取input_ids和labels，并保存到类的属性中\n",
    "        self.input_ids = data_dict[\"input_ids\"]\n",
    "        self.labels = data_dict[\"labels\"]\n",
    "\n",
    "        # 重写__len__方法，返回处理后的input_ids的长度，即数据集的大小\n",
    "\n",
    "    def __len__(self):\n",
    "        return len(self.input_ids)\n",
    "\n",
    "        # 重写__getitem__方法，使得可以通过索引i获取数据集中第i个样本的input_ids和labels\n",
    "\n",
    "    def __getitem__(self, i):\n",
    "        return dict(input_ids=self.input_ids[i], labels=self.labels[i])\n"
   ],
   "id": "d94db5a6f3fcbe52",
   "outputs": [],
   "execution_count": 4
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-27T22:48:45.762531Z",
     "start_time": "2025-07-27T22:48:45.753078Z"
    }
   },
   "cell_type": "code",
   "source": [
    "# 定义一个名为 DataCollatorForChatDataset 的类，它继承自 object 类。\n",
    "class DataCollatorForChatDataset(object):\n",
    "    \"\"\"\n",
    "    Collate examples for supervised fine-tuning.\n",
    "    \"\"\"\n",
    "    # 初始化函数，这里没有接收特定的参数。\n",
    "    def __init__(self):\n",
    "        # 初始化一个属性 padding_value，并设置其值为0。这个属性后续用于 padding 操作。\n",
    "        self.padding_value = 0\n",
    "\n",
    "        # 定义一个特殊方法 __call__，这使得类的实例能够像函数一样被调用。\n",
    "\n",
    "    def __call__(self, instances):\n",
    "        # instances 参数应该是一个包含多个实例的列表，每个实例都是一个字典，包含 'input_ids' 和 'labels'。\n",
    "        # 通过列表推导式，分别提取每个实例的 'input_ids' 和 'labels'，并组成新的列表。\n",
    "        input_ids, labels = tuple([instance[key] for instance in instances] for key in (\"input_ids\", \"labels\"))\n",
    "\n",
    "        # 使用 torch.nn.utils.rnn.pad_sequence 函数对 input_ids 列表进行 padding 操作，使得所有的序列长度一致。\n",
    "        # 参数 batch_first=True 表示输入的数据是 batch-major，即第一个维度是 batch 维度。\n",
    "        # 参数 padding_value=self.padding_value 表示用 0 进行 padding。\n",
    "        input_ids = torch.nn.utils.rnn.pad_sequence(input_ids, batch_first=True, padding_value=self.padding_value)\n",
    "\n",
    "        # 与上面类似，对 labels 列表进行 padding 操作，但是这里使用 -100 进行 padding。\n",
    "        labels = torch.nn.utils.rnn.pad_sequence(labels, batch_first=True, padding_value=-100)\n",
    "\n",
    "        # 返回一个字典，包含经过处理后的 input_ids, labels, 以及根据 input_ids 生成的 attention_mask。\n",
    "        # attention_mask 是一个布尔类型的张量，它的作用是在模型处理输入时，告诉模型哪些部分是真正的内容，哪些部分是 padding。\n",
    "        return dict(\n",
    "            input_ids=input_ids,\n",
    "            labels=labels,\n",
    "            attention_mask=input_ids.ne(self.padding_value),\n",
    "        )"
   ],
   "id": "dfbd3021d2c1bd56",
   "outputs": [],
   "execution_count": 5
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-07-27T22:48:46.660373Z",
     "start_time": "2025-07-27T22:48:46.641780Z"
    }
   },
   "cell_type": "code",
   "source": [
    "if __name__ == '__main__':\n",
    "    ChatDataset()\n",
    "    print(tokenizer.pad_token_id)"
   ],
   "id": "initial_id",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "USER [30910, 34607, 55622, 56657, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54708, 33120, 54556, 56657]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [30910, 34607, 55622, 43809, 56657, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 31934, 54546, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54708, 33120, 54556, 56657]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 33277, 31827, 56657, 31514]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 55073, 48875, 39376, 31155]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54708, 33120, 54556, 56657]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54573, 36647, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 55073, 48875, 39376, 31155]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [30910, 34607, 55622, 43809, 56657, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 33277, 31827, 56657, 31514]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [30910, 34607, 55622, 43809, 56657, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 33277, 31827, 56657, 31514]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 55073, 48875, 39376, 31155]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54573, 36647, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 33277, 31827, 56657, 31514]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 55073, 48875, 39376, 31155]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54708, 33120, 54556, 56657]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 31934, 54546, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 55073, 48875, 39376, 31155]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [30910, 34607, 55622, 43809, 56657, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 31934, 54546, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 55622, 56657, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [30910, 34607, 55622, 43809, 56657, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 33277, 31827, 56657, 31514]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 55622, 56657, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [30910, 34607, 55622, 43809, 56657, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54573, 36647, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 33277, 31827, 56657, 31514]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 55073, 48875, 39376, 31155]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [30910, 34607, 55622, 43809, 56657, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 55622, 56657, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54573, 36647, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 55622, 56657, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54708, 33120, 54556, 56657]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 31934, 54546, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54573, 36647, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 31934, 54546, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 55622, 56657, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54573, 36647, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 33277, 31827, 56657, 31514]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54708, 33120, 54556, 56657]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 31934, 54546, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 55622, 56657, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54573, 36647, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 31934, 54546, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54708, 33120, 54556, 56657]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 55073, 48875, 39376, 31155]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54573, 36647, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [30910, 34607, 55622, 43809, 56657, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 55622, 56657, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [30910, 34607, 55622, 43809, 56657, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 31934, 54546, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 34607, 55622, 56657, 31514]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54708, 33120, 54556, 56657]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 33277, 31827, 56657, 31514]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 55073, 48875, 39376, 31155]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54708, 33120, 54556, 56657]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 33277, 31827, 56657, 31514]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "USER [30910, 55073, 48875, 39376, 31155]\n",
      "ASSISTANT [34211, 55483, 56734, 56734, 31123, 46807, 31822, 34821, 34712, 35200, 31155, 2]\n",
      "USER [36474, 54573, 36647, 31514]\n",
      "ASSISTANT [34211, 54579, 30943, 30940, 30939, 30943, 54540, 35408, 54579, 35666, 31123, 31690, 55022, 35059, 54536, 32303, 31123, 31843, 56548, 32365, 46707, 43809, 31155, 2]\n",
      "USER [36474, 54558, 31934, 54546, 41172]\n",
      "ASSISTANT [34211, 31628, 40322, 33214, 34821, 56657, 31123, 33485, 54628, 38514, 32719, 32108, 31155, 2]\n",
      "0\n"
     ]
    }
   ],
   "execution_count": 6
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "18581e2dc2e0b84b"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
